import re
from typing import Optional
from typing import Optional

import re
from typing import Optional, List, Tuple


def extract_doc_comment(content: str) -> Optional[str]:
    lines = content.split("\n")
    length = len(lines)
    res = []
    for i in range(length - 1):
        n = length - i - 2
        line = lines[n].strip()
        if line.startswith("/**"):
            res.append(line[3:])
            break
        elif line.startswith("*/") or not line:
            continue
        elif line.startswith("*"):
            res.append(line[1:])
        else:
            break
    res.reverse()
    return "\n".join(res).strip()


def extract_name_and_desc(content) -> str:
    doc_comment = extract_doc_comment(content)

    if not doc_comment:
        return ""

    lines = [line.strip() for line in doc_comment.split("\n")]

    # 去除所有 @ 行
    for i in range(len(lines)):
        if lines[i].startswith("@"):
            lines[i] = ""

    return "\n".join(lines).strip()
